/**
 * dutil: TimerCounter.java
 */

package net.acoder.util;


/**
 * @author Daniel
 * @date 2009-11-25 上午09:47:25
 * 
 */
public class TimerCounter {
    private long   b, e, diff;
    private String format = "%4d:%2d:%2d.%3d";

    public TimerCounter() {
    }

    public void b() {
        b = System.currentTimeMillis();
    }

    public void e() {
        e = System.currentTimeMillis();
        diff = e - b;
        print();
        b = e;
    }

    private void print() {
        long hour = diff / 3600 / 1000;
        long min = diff / 1000 % 3600 / 60;
        long sec = diff / 1000 % 60;
        long msec = diff % 1000;
        System.out.println(String.format(format, hour, min, sec, msec));
    }
}
